package com.tsu.mall.order.Controller;


import com.tsu.mall.common.VO.LayuiTableVO;
import com.tsu.mall.common.entity.Member;
import com.tsu.mall.common.service.IMemberService;
import com.tsu.mall.common.util.RequestUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/updatePassword")
public class updatePasswordPageController {
    @Autowired
    private IMemberService iMemberService;

    @GetMapping("/updatePasswordPage")
    public String updatePasswordPage(Model model){
        //查询当前登录用户信息
        Member currentMember=iMemberService.doSelectById(RequestUtil.getCurrent().getId());
        model.addAttribute("currentMember",currentMember);
        return "updatePassword";
    }

    @PostMapping("/updatePasswordByMemberId")
    @ResponseBody
    public LayuiTableVO updatePasswordByMemberId(String prePassword, String newPassword, String confirmPassword){
        return iMemberService.updatePasswordByMemberId(RequestUtil.getCurrent().getId(),prePassword,newPassword,confirmPassword);
    }
}
